#!/usr/bin/python
import psycopg2
import pprint

print psycopg2.__version__
print " import success "
conn = psycopg2.connect(database='logistics',host='localhost',user='postgres',password='postgres')
c=conn.cursor()
print 'get the cursor'
sql = "select count(*) from task where description = %s ;"
c.execute(sql,("23242",))
records = c.fetchall()
print "your have %d tasks"%(records[0])
print "like the description"
pprint.pprint(records)

print "select the posNo "
sql = "select count(*) from task where \"posNo\" = %s ;"
c.execute(sql,("11",))
records = c.fetchall()
pprint.pprint(records)

deviceid="234234"
state=0
print "select the posNo"
sql = "select count(*) from task where state = %s and \"posNo\" = %s;"
c.execute(sql,(state,deviceid,))
records = c.fetchall()
pprint.pprint(records)
